\documentclass[a4paper,twoside]{article}
\usepackage[procnames,noindent]{lgrind}
\usepackage{fancyhdr,a4wide}
\usepackage{german}
\usepackage{makeidx}
\pagestyle{fancy}

\makeindex

\begin{document}
\renewcommand{\footrulewidth}{0.4pt}
\fancyhead[C]{\lgrindhead}
\fancyhead[LO,RE]{\lgrindfilesize~Bytes\\\lgrindmodtime}
\fancyhead[RO,LE]{\bfseries \lgrindfilename\\\lgrindmodday.\lgrindmodmonth.\lgrindmodyear}
\fancyfoot[C]{\bfseries\thepage}
\setlength{\headheight}{24pt}
\begin{lgrind}
\BGfont
\File{huffman.c}{2004}{3}{9}{0:45}{4269}
\L{\LB{\K{\#include}_\<\V{stdio}.\V{h}\>}}
\L{\LB{\K{\#include}_\<\V{stdlib}.\V{h}\>}}
\L{\LB{\K{\#include}_\S{}\3huffman.h\3\SE{}}}
\L{\LB{\K{\#include}_\S{}\3bf.h\3\SE{}}}
\L{\LB{}}
\L{\LB{\V{huff\_tree}_\V{thetree}_=_\{\V{NULL},_\V{NULL},_\{\V{NULL}\},_\{\V{NULL}\},_\N{0}\};}}
\L{\LB{}}
\index{huff\_code\_tostring}\Proc{huff\_code\_tostring}\L{\LB{\K{void}_\V{huff\_code\_tostring}_(\V{huff\_code}_\V{this})_\{}}
\L{\LB{}\Tab{2}{\K{int}_\V{i};}}
\L{\LB{}\Tab{2}{\K{for}_(\V{i}_=_\V{this}\-\!\>\V{length}_\-_\N{1};_\V{i}_\>=_\N{0};_\V{i}\-\-)_\{}}
\L{\LB{}\Tab{4}{\V{putchar}_(((\V{this}\-\!\>\V{bits}_\>\>_\V{i})_\&_\N{1L})_?_\S{}{'}1{'}\SE{}_:_\S{}{'}0{'}\SE{});}}
\L{\LB{}\Tab{2}{\}}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_putcode}\Proc{huff\_putcode}\L{\LB{\K{void}_\V{huff\_putcode}_(\V{bf\_stream}_\V{bf},_\V{huff\_code}_\V{c})_\{}}
\L{\LB{}\Tab{2}{\K{int}_\V{i};}}
\L{\LB{}\Tab{2}{\K{for}_(\V{i}_=_\V{c}\-\!\>\V{length}_\-_\N{1};_\V{i}_\>=_\N{0};_\V{i}\-\-)_\{}}
\L{\LB{}\Tab{4}{\V{bf\_putbit}_(\V{bf},_((\V{c}\-\!\>\V{bits}_\>\>_\V{i})_\&_\N{1L}));}}
\L{\LB{}\Tab{2}{\}}\Tab{5}{}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_node\_new}\Proc{huff\_node\_new}\L{\LB{\V{huff\_node}_\V{huff\_node\_new}_()_\{}}
\L{\LB{}\Tab{2}{\V{huff\_node}_\V{this}_=_(\V{huff\_node})_\V{calloc}_(\N{1},_\K{sizeof}_(\K{struct}_\V{huff\_node\_struct}));}}
\L{\LB{}\Tab{2}{\K{return}_\V{this};}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_node\_init}\Proc{huff\_node\_init}\L{\LB{\K{void}_\V{huff\_node\_init}_(\V{huff\_node}_\V{this},_\K{int}_\V{w},_\K{int}_\V{c},}}
\L{\LB{}\Tab{21}{\V{huff\_node}_\V{f},_\V{huff\_node}_\V{l},_\V{huff\_node}_\V{r},_\K{int}_\V{i})_\{}}
\L{\LB{}\Tab{2}{\V{this}\-\!\>\V{w}_=_\V{w};_\V{this}\-\!\>\V{c}_=_\V{c};_\V{this}\-\!\>\V{gdbh\_index}_=_\V{i};}}
\L{\LB{}\Tab{2}{\V{this}\-\!\>\V{father}_=_\V{f};_\V{this}\-\!\>\V{left}_=_\V{l};_\V{this}\-\!\>\V{right}_=_\V{r};}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_node\_tostring}\Proc{huff\_node\_tostring}\L{\LB{\K{void}_\V{huff\_node\_tostring}_(\V{huff\_node}_\V{this})_\{}}
\L{\LB{}\Tab{2}{\V{printf}_(\S{}\3[\%c_\|\%2d]\3\SE{},_\V{this}\-\!\>\V{c}_?_\V{this}\-\!\>\V{c}_:_\S{}{'}\_{'}\SE{},_\V{this}\-\!\>\V{w});}}
\L{\LB{\}}}
\L{\LB{}}
\index{\_huff\_tree\_tostring}\Proc{\_huff\_tree\_tostring}\L{\LB{\K{void}_\V{\_huff\_tree\_tostring}_(\V{huff\_node}_\V{n},_\K{int}_\V{depth},_\K{long}_\V{mask})_\{}}
\L{\LB{}\Tab{2}{\K{int}_\V{i};}}
\L{\LB{}\Tab{2}{\K{for}_(\V{i}_=_\N{0};_\V{i}_\<_\V{depth};_\V{i}++)_\{}}
\L{\LB{}\Tab{4}{\K{if}_(\V{mask}_\&_(\N{1}_\<\<_\V{i}))_\{}}
\L{\LB{}\Tab{6}{\V{putchar}_(\S{}{'}_{'}\SE{});}\Tab{22}{\V{putchar}_(\S{}{'}\|{'}\SE{});}}
\L{\LB{}\Tab{4}{\}}}
\L{\LB{}\Tab{4}{\K{else}_\{}}
\L{\LB{}\Tab{6}{\V{putchar}_(\S{}{'}_{'}\SE{});}}
\L{\LB{}\Tab{6}{\V{putchar}_(\S{}{'}_{'}\SE{});}}
\L{\LB{}\Tab{4}{\}}}
\L{\LB{}\Tab{2}{\}}}
\L{\LB{}\Tab{2}{\V{printf}_(\S{}\3_+\-\-\3\SE{});}}
\L{\LB{}\Tab{2}{\V{huff\_node\_tostring}_(\V{n});}}
\L{\LB{}\Tab{2}{\V{printf}_(\S{}\3\2n\3\SE{});}}
\L{\LB{}\Tab{2}{\K{if}_(\V{n}\-\!\>\V{left})}}
\L{\LB{}\Tab{4}{\V{\_huff\_tree\_tostring}_(\V{n}\-\!\>\V{left},_\V{depth}_+_\N{1},_\V{mask}_\|_(\N{1}_\<\<_(\V{depth}_+_\N{1})));}}
\L{\LB{}\Tab{2}{\K{if}_(\V{n}\-\!\>\V{right})}}
\L{\LB{}\Tab{4}{\V{\_huff\_tree\_tostring}_(\V{n}\-\!\>\V{right},_\V{depth}_+_\N{1},_\V{mask});}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_tree\_tostring}\Proc{huff\_tree\_tostring}\L{\LB{\K{void}_\V{huff\_tree\_tostring}_()_\{}}
\L{\LB{}\Tab{2}{\V{printf}_(\S{}\3DynaHuff_with_\%d_nodes\2n\3\SE{},_\V{thetree}.\V{count});}}
\L{\LB{}\Tab{2}{\V{\_huff\_tree\_tostring}_(\V{thetree}.\V{root},_\N{0},_\N{0L});}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_node\_exchange}\Proc{huff\_node\_exchange}\L{\LB{\K{void}_\V{huff\_node\_exchange}_(\V{huff\_node}_\V{q},_\V{huff\_node}_\V{r})_\{}}
\L{\LB{}\Tab{2}{\K{int}_\V{t};_\V{huff\_node}_\V{n};}}
\L{\LB{}\Tab{2}{}}
\L{\LB{}\Tab{2}{\V{t}_=_\V{q}\-\!\>\V{w};_\V{q}\-\!\>\V{w}_=_\V{r}\-\!\>\V{w};_\V{r}\-\!\>\V{w}_=_\V{t};}}
\L{\LB{}\Tab{2}{\V{t}_=_\V{q}\-\!\>\V{c};_\V{q}\-\!\>\V{c}_=_\V{r}\-\!\>\V{c};_\V{r}\-\!\>\V{c}_=_\V{t};}}
\L{\LB{}\Tab{2}{\V{n}_=_\V{q}\-\!\>\V{left};_\V{q}\-\!\>\V{left}_=_\V{r}\-\!\>\V{left};_\V{r}\-\!\>\V{left}_=_\V{n};}}
\L{\LB{}\Tab{2}{\V{n}_=_\V{q}\-\!\>\V{right};_\V{q}\-\!\>\V{right}_=_\V{r}\-\!\>\V{right};_\V{r}\-\!\>\V{right}_=_\V{n};}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\K{if}_(\V{q}\-\!\>\V{left})_\V{q}\-\!\>\V{left}\-\!\>\V{father}_=_\V{q};}}
\L{\LB{}\Tab{2}{\K{if}_(\V{q}\-\!\>\V{right})_\V{q}\-\!\>\V{right}\-\!\>\V{father}_=_\V{q};}}
\L{\LB{}\Tab{2}{\K{if}_(\V{r}\-\!\>\V{left})_\V{r}\-\!\>\V{left}\-\!\>\V{father}_=_\V{r};}}
\L{\LB{}\Tab{2}{\K{if}_(\V{r}\-\!\>\V{right})_\V{r}\-\!\>\V{right}\-\!\>\V{father}_=_\V{r};}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\K{if}_(\V{q}\-\!\>\V{c}_!=_\-\N{1})_\V{thetree}.\V{chars}[\V{q}\-\!\>\V{c}]_=_\V{q};}}
\L{\LB{}\Tab{2}{\K{if}_(\V{r}\-\!\>\V{c}_!=_\-\N{1})_\V{thetree}.\V{chars}[\V{r}\-\!\>\V{c}]_=_\V{r};}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_node\_isgdbh}\Proc{huff\_node\_isgdbh}\L{\LB{\K{int}_\V{huff\_node\_isgdbh}_(\V{huff\_node}_\V{this})_\{}}
\L{\LB{}\Tab{2}{\K{if}_(\V{this}\-\!\>\V{gdbh\_index}_==_\N{0})}}
\L{\LB{}\Tab{4}{\K{return}_\N{1};}}
\L{\LB{}\Tab{2}{\V{huff\_node}_\V{n}_=_\V{thetree}.\V{gdbh}[\V{this}\-\!\>\V{gdbh\_index}_\-_\N{1}];}}
\L{\LB{}\Tab{2}{\K{return}_\V{n}\-\!\>\V{w}_\>_\V{this}\-\!\>\V{w};}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_node\_eob}\Proc{huff\_node\_eob}\L{\LB{\V{huff\_node}_\V{huff\_node\_eob}_(\V{huff\_node}_\V{this})_\{}}
\L{\LB{}\Tab{2}{\V{huff\_node}_\V{n}_=_\V{this};}}
\L{\LB{}\Tab{2}{\K{while}_(!\V{huff\_node\_isgdbh}_(\V{n}))}}
\L{\LB{}\Tab{4}{\V{n}_=_\V{thetree}.\V{gdbh}[\V{n}\-\!\>\V{gdbh\_index}_\-_\N{1}];}}
\L{\LB{}\Tab{2}{}}
\L{\LB{}\Tab{2}{\K{if}_(\V{n}_==_\V{this}\-\!\>\V{father})}}
\L{\LB{}\Tab{4}{\K{return}_\V{this};}}
\L{\LB{}\Tab{2}{\K{return}_\V{n};}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_tree\_update}\Proc{huff\_tree\_update}\L{\LB{\K{void}_\V{huff\_tree\_update}_(\V{huff\_node}_\V{q})_\{}}
\L{\LB{}\Tab{2}{\V{huff\_node}_\V{t},_\V{n}_=_\V{q};}}
\L{\LB{}\Tab{2}{\K{while}_(\V{n})_\{}}
\L{\LB{}\Tab{4}{\V{t}_=_\V{huff\_node\_eob}_(\V{n});}}
\L{\LB{}\Tab{4}{\K{if}_(\V{t}_==_\V{n})_\{}}
\L{\LB{}\Tab{6}{\V{n}\-\!\>\V{w}++;}}
\L{\LB{}\Tab{6}{\V{n}_=_\V{n}\-\!\>\V{father};}}
\L{\LB{}\Tab{4}{\}_\K{else}_\{}}
\L{\LB{}\Tab{6}{\V{huff\_node\_exchange}_(\V{n},_\V{t});}}
\L{\LB{}\Tab{6}{\V{n}_=_\V{t};}}
\L{\LB{}\Tab{4}{\}}}
\L{\LB{}\Tab{2}{\}}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_tree\_modify}\Proc{huff\_tree\_modify}\L{\LB{\K{void}_\V{huff\_tree\_modify}_(\K{int}_\V{c})_\{}}
\L{\LB{}\Tab{2}{\V{huff\_node}_\V{q};}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{q}_=_\V{thetree}.\V{chars}[\V{c}];}}
\L{\LB{}\Tab{2}{\K{if}_(!\V{q})_\{}}
\L{\LB{}\Tab{4}{\V{huff\_node}_\V{new\_special},_\V{n};}}
\L{\LB{}\Tab{4}{\V{new\_special}_=_\V{huff\_node\_new}_();}}
\L{\LB{}\Tab{4}{\V{n}_=_\V{huff\_node\_new}_();}}
\L{\LB{}}
\L{\LB{}\Tab{4}{\V{huff\_node\_init}_(\V{new\_special},_\N{1},_\-\N{1},}}
\L{\LB{}\Tab{20}{\V{thetree}.\V{special},_\V{NULL},_\V{n},_\V{thetree}.\V{count});}}
\L{\LB{}\Tab{4}{\V{thetree}.\V{gdbh}[\V{thetree}.\V{count}++]_=_\V{new\_special};}}
\L{\LB{}}
\L{\LB{}\Tab{4}{\V{huff\_node\_init}_(\V{n},_\N{1},_\V{c},_\V{new\_special},}}
\L{\LB{}\Tab{20}{\V{NULL},_\V{NULL},_\V{thetree}.\V{count});}}
\L{\LB{}\Tab{4}{\V{thetree}.\V{gdbh}[\V{thetree}.\V{count}++]_=_\V{n};}}
\L{\LB{}\Tab{4}{\V{thetree}.\V{chars}[\V{c}]_=_\V{n};}}
\L{\LB{}}
\L{\LB{}\Tab{4}{\V{thetree}.\V{special}\-\!\>\V{left}_=_\V{new\_special};}}
\L{\LB{}\Tab{4}{\V{q}_=_\V{thetree}.\V{special};}}
\L{\LB{}\Tab{4}{\V{thetree}.\V{special}_=_\V{new\_special};}}
\L{\LB{}\Tab{2}{\}}}
\L{\LB{}\Tab{2}{\V{huff\_tree\_update}_(\V{q});}\Tab{25}{}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_node\_get\_code}\Proc{huff\_node\_get\_code}\L{\LB{\K{void}_\V{huff\_node\_get\_code}_(\V{huff\_node}_\V{this},_\V{huff\_code}_\V{res})_\{}}
\L{\LB{}\Tab{2}{\V{huff\_node}_\V{n}_=_\V{this},_\V{f}_=_\V{this}\-\!\>\V{father};}}
\L{\LB{}\Tab{2}{\K{int}_\V{length}_=_\N{0},_\V{code}_=_\N{0};}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\K{while}_(\V{f})_\{}}
\L{\LB{}\Tab{4}{\K{if}_(\V{f}\-\!\>\V{right}_==_\V{n})}}
\L{\LB{}\Tab{6}{\V{code}_\|=_\N{1}_\<\<_\V{length};}}
\L{\LB{}\Tab{4}{\V{length}++;}}
\L{\LB{}\Tab{4}{\V{n}_=_\V{f};}}
\L{\LB{}\Tab{4}{\V{f}_=_\V{f}\-\!\>\V{father};}}
\L{\LB{}\Tab{2}{\}}}
\L{\LB{}\Tab{2}{\V{res}\-\!\>\V{length}_=_\V{length};}}
\L{\LB{}\Tab{2}{\V{res}\-\!\>\V{bits}_=_\V{code};}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_tree\_init}\Proc{huff\_tree\_init}\L{\LB{\K{void}_\V{huff\_tree\_init}_(\K{int}_\V{c})_\{}}
\L{\LB{}\Tab{2}{\V{huff\_node}_\V{root}_=_\V{huff\_node\_new}_();}}
\L{\LB{}\Tab{2}{\V{huff\_node}_\V{anode}_=_\V{huff\_node\_new}_();}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{huff\_node\_init}_(\V{root},_\N{1},_\-\N{1},_\V{NULL},_\V{NULL},_\V{anode},_\N{0});}}
\L{\LB{}\Tab{2}{\V{huff\_node\_init}_(\V{anode},_\N{1},_\V{c},_\V{root},_\V{NULL},_\V{NULL},_\N{1});}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{thetree}.\V{count}_=_\N{2};}}
\L{\LB{}\Tab{2}{\V{thetree}.\V{root}_=_\V{root};}}
\L{\LB{}\Tab{2}{\V{thetree}.\V{special}_=_\V{root};}}
\L{\LB{}\Tab{2}{\V{thetree}.\V{gdbh}[\N{0}]_=_\V{root};}}
\L{\LB{}\Tab{2}{\V{thetree}.\V{gdbh}[\N{1}]_=_\V{anode};}}
\L{\LB{}\Tab{2}{\V{thetree}.\V{chars}[\V{c}]_=_\V{anode};}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_getcode}\Proc{huff\_getcode}\L{\LB{\K{int}_\V{huff\_getcode}_(\K{int}_\V{c},_\V{huff\_code}_\V{res})_\{}}
\L{\LB{}\Tab{2}{\V{huff\_node}_\V{n}_=_\V{thetree}.\V{chars}[\V{c}];}}
\L{\LB{}\Tab{2}{\K{if}_(!\V{n})_\K{return}_\N{0};}}
\L{\LB{}\Tab{2}{\V{huff\_node\_get\_code}_(\V{n},_\V{res});}}
\L{\LB{}\Tab{2}{\K{return}_\N{1};}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_special\_code}\Proc{huff\_special\_code}\L{\LB{\K{void}_\V{huff\_special\_code}_(\V{huff\_code}_\V{res})_\{}}
\L{\LB{}\Tab{2}{\V{huff\_node}_\V{n}_=_\V{thetree}.\V{special};}}
\L{\LB{}\Tab{2}{\V{huff\_node\_get\_code}_(\V{n},_\V{res});}}
\L{\LB{}\Tab{2}{\V{res}\-\!\>\V{bits}_\<\<=_\N{1};}}
\L{\LB{}\Tab{2}{\V{res}\-\!\>\V{length}++;}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_node\_isspecial}\Proc{huff\_node\_isspecial}\L{\LB{\K{int}_\V{huff\_node\_isspecial}_(\V{huff\_node}_\V{this})_\{}}
\L{\LB{}\Tab{2}{\K{return}_(\V{this}\-\!\>\V{left}_==_\V{NULL})_\&\&_(\V{this}\-\!\>\V{right}_!=_\V{NULL});}}
\L{\LB{\}}}
\L{\LB{}}
\index{huff\_node\_isleaf}\Proc{huff\_node\_isleaf}\L{\LB{\K{int}_\V{huff\_node\_isleaf}_(\V{huff\_node}_\V{this})_\{}}
\L{\LB{}\Tab{2}{\K{return}_(\V{this}\-\!\>\V{left}_==_\V{NULL})_\&\&_(\V{this}\-\!\>\V{right}_==_\V{NULL});}}
\L{\LB{\}}}
\end{lgrind}
\printindex
\end{document}